home *** CD-ROM | disk | FTP | other *** search
/ Just Call Me Internet / Just Call Me Internet.iso / prog / atari / c / stngpasm / pure_c / include / sting / net_tcon.sh < prev    next >
Encoding:
Text File  |  1997-08-09  |  16.2 KB  |  553 lines

  1. ;----------------------------------------------------------------------------
  2. ;File name:    NET_TCON.SH            Revision date:    1997.08.04
  3. ;Creator:    Ulf Ronald Andersson        Creation date:    1997.07.31
  4. ;(c)1997 by:    Ulf Ronald Andersson        All rights reserved
  5. ;----------------------------------------------------------------------------
  6. ;Required header declarations:
  7. ;
  8. ;    .include    "uran\STRUCT.SH"
  9. ;    .include    "uran\URAn_SYS.SH"
  10. ;    .include    "sting\TRANSPRT.SH"
  11. ;    .include    "sting\DOMAIN.SH"
  12. ;    .include    "sting\NET_TCON.SH"
  13. ;
  14. ;copy the above to the header of your program and 'uncomment' the includes
  15. ;----------------------------------------------------------------------------
  16. ;Purpose:
  17. ;
  18. ;The macros declared here will handle the translation of time and date values
  19. ;between three formats:  The internal 2*16 bit code of TOS, the normal 32 bit
  20. ;network time format of internet, and the normal human format where each time
  21. ;unit is separate from the others.
  22. ;----------------------------------------------------------------------------
  23. ;NB: Having used any of these macros, you have to include a call like this:
  24. ;
  25. ;        make    TCON_links
  26. ;
  27. ;    This must be somewhere in the executable code, after all 'tcon_' macros
  28. ;    that are to be used in the program have been called at least once.
  29. ;----------------------------------------------------------------------------
  30. ;Available macros and their usage:
  31. ;
  32. ;
  33. ;tcon_real2tos    The TOS time of a tcon struct is loaded from TOS realtime
  34. ;tcon_tos2real    TOS realtime is loaded from the TOS time of a tcon struct
  35. ;tcon_man2tos    Human time of a tcon struct is converted into its TOS time
  36. ;tcon_tos2man    TOS time of a tcon struct is converted into its human time
  37. ;tcon_man2net    Human time of a tcon struct is converted into network time
  38. ;tcon_net2man    Network time of a tcon struct is converted into human time
  39. ;tcon_is_summer    Flags summertime with -1 and non-summer with 0
  40. ;tcon_rd_zone    Converts data from sting variable TIME_ZONE to zoneseconds
  41. ;tcon_rd_summer    Converts data from sting variable TIME_SUMMER to tcon_summer
  42. ;
  43. ;All of these macros expect a pointer to a 'tcon' structure in a0 and they
  44. ;restore all CPU address and data registers to original values on exit.
  45. ;
  46. ; NB:    use "ds.b    sizeof_tcon" to reserve storage for a tcon structure.
  47. ;
  48. ;+NB:    TIME_ZONE has a range of "-1440" to "+1440" in minutes ahead of GMT
  49. ;          so for Germany or Sweden (for example) "+60" is correct.
  50. ;    tcon_zoneseconds has a range of -86400 to +86400 in seconds, which
  51. ;          corresponds to TIME_ZONE multiplied by 60
  52. ;----------------------------------------------------------------------------
  53. ;The tcon structure:
  54. ;
  55.     struct    tcon
  56.     uint32    tcon_net_time        ;network time from 00:00 Jan 1 1900 GMT
  57.     int32    tcon_zoneseconds    ;max +/- 45000  (== 12.5 hours)
  58.     uint16    tcon_tos_date        ;bitpacked date of Atari TOS
  59.     uint16    tcon_tos_time        ;bitpacked time of Atari TOS
  60.     uint16    tcon_man_year        ;human year
  61.     uint16    tcon_man_month        ;human month
  62.     uint16    tcon_man_date        ;human date
  63.     uint16    tcon_man_hour        ;human hour
  64.     uint16    tcon_man_minute        ;human minute
  65.     uint16    tcon_man_second        ;human second
  66.     uint16    tcon_man_weekday    ;human weekday
  67.     d_alias    tcon_summer        ;sub_struct for daylight savings
  68.     uint8    tcon_summer_start_month    ;\
  69.     uint8    tcon_summer_start_date    ; \/ In this period another hour
  70.     uint8    tcon_summer_end_month    ; /\ is added to the zone time
  71.     uint8    tcon_summer_end_date    ;/   (Zero values disable this)
  72.     d_end    tcon
  73. ;
  74. ;NB:    weekday support is limited to the conversion tcon_net2man.
  75. ;    For tos and human formats that need weekday updated, you must
  76. ;    first convert to network format, and then to human format.
  77. ;    This is not needed unless weekday is necessary.
  78. ;
  79. ;    examples of conversions making tcon_weekday valid:
  80. ;
  81. ;    network    format    => tcon_net2man
  82. ;    human format    => tcon_man2net + tcon_net2man
  83. ;    tos format    => tcon_tos2man + tcon_man2net + tcon_net2man
  84. ;
  85. ;----------------------------------------------------------------------------
  86. ;
  87. NET_JAN_1980    equ    2524521600    ;1980.01.01 was a tuesday :-)
  88. NET_DAY        equ    86400
  89. ;
  90. ;----------------------------------------------------------------------------
  91. ;
  92. .MACRO    TCON_links
  93.     _unidef    tcon_real2tos
  94.     _unidef    tcon_tos2real
  95.     _unidef    tcon_man2tos
  96.     _unidef    tcon_tos2man
  97.     _unidef    tcon_man2net
  98.     _unidef    tcon_net2man
  99.     _unidef    tcon_rd_zone
  100.     _unidef    tcon_rd_summer
  101.     _unidef    tcon_is_summer
  102. .ENDM    TCON_links
  103. ;
  104.     _unidec    tcon_real2tos
  105.     _unidec    tcon_tos2real
  106.     _unidec    tcon_man2tos
  107.     _unidec    tcon_tos2man
  108.     _unidec    tcon_man2net
  109.     _unidec    tcon_net2man
  110.     _unidec    tcon_rd_zone
  111.     _unidec    tcon_rd_summer
  112.     _unidec    tcon_is_summer
  113. ;
  114. ;-------------------------------------
  115. ;
  116. .MACRO    tcon_real2tos
  117.     _uniref    tcon_real2tos
  118.     jsr    code_tcon_real2tos
  119. .ENDM    tcon_real2tos
  120. ;
  121. .MACRO    code_tcon_real2tos
  122.     movem.l    d0-d4/a0-a3,-(sp)
  123.     move.l    a0,a3        ;a3 -> tcon structure
  124.     gemdos    Tgetdate
  125.     move    d0,d3
  126.     gemdos    Tgettime
  127.     move    d0,d4
  128.     gemdos    Tgetdate
  129.     cmp    d0,d3
  130.     beq.s    .have_time
  131.     move    d0,d3
  132.     gemdos    Tgettime
  133.     move    d0,d4
  134. .have_time:
  135.     move    d3,tcon_tos_date(a3)
  136.     move    d4,tcon_tos_time(a3)
  137.     movem.l    (sp)+,d0-d4/a0-a3
  138.     rts
  139. .ENDM    code_tcon_real2tos
  140. ;
  141. ;-------------------------------------
  142. ;
  143. .MACRO    tcon_tos2real
  144.     _uniref    tcon_tos2real
  145.     jsr    code_tcon_tos2real
  146. .ENDM    tcon_tos2real
  147. ;
  148. .MACRO    code_tcon_tos2real
  149.     movem.l    d0-d2/a0-a3,-(sp)
  150.     move.l    a0,a3        ;a3 -> tcon structure
  151.     gemdos    Tsettime,tcon_tos_time(a3)
  152.     gemdos    Tsetdate,tcon_tos_date(a3)
  153.     movem.l    (sp)+,d0-d2/a0-a3
  154.     rts
  155. .ENDM    code_tcon_tos2real
  156. ;
  157. ;-------------------------------------
  158. ;
  159. .MACRO    tcon_tos2man
  160.     _uniref    tcon_tos2man
  161.     jsr    code_tcon_tos2man
  162. .ENDM    tcon_tos2man
  163. ;
  164. .MACRO    code_tcon_tos2man
  165. ;Sub converts TOS time to human time
  166.     movem.l    d0/d1,-(sp)
  167.     move    tcon_tos_date(a0),d0
  168.     move    d0,d1
  169.     and    #1<<5-1,d1
  170.     move    d1,tcon_man_date(a0)
  171.     lsr    #5,d0
  172.     move    d0,d1
  173.     and    #1<<4-1,d1
  174.     move    d1,tcon_man_month(a0)
  175.     lsr    #4,d0
  176.     add    #1980,d0
  177.     move    d0,tcon_man_year(a0)
  178. ;
  179.     move    tcon_tos_time(a0),d0
  180.     move    d0,d1
  181.     and    #1<<5-1,d1
  182.     add    d1,d1
  183.     move    d1,tcon_man_second(a0)
  184.     lsr    #5,d0
  185.     move    d0,d1
  186.     and    #1<<6-1,d1
  187.     move    d1,tcon_man_minute(a0)
  188.     lsr    #6,d0
  189.     move    d0,tcon_man_hour(a0)
  190.     movem.l    (sp)+,d0/d1
  191.     rts
  192. .ENDM    code_tcon_tos2man
  193. ;
  194. ;-------------------------------------
  195. ;
  196. .MACRO    tcon_man2tos
  197.     _uniref    tcon_man2tos
  198.     jsr    code_tcon_man2tos
  199. .ENDM    tcon_man2tos
  200. ;
  201. .MACRO    code_tcon_man2tos
  202. ;Sub converts human time to TOS time
  203.     movem.l    d0/d1,-(sp)
  204.     move    tcon_man_year(a0),d1
  205.     sub    #1980,d1
  206.     asl    #4,d1
  207.     move    tcon_man_month(a0),d0
  208.     and    #1<<4-1,d0
  209.     or    d0,d1
  210.     asl    #5,d1
  211.     move    tcon_man_date(a0),d0
  212.     and    #1<<5-1,d0
  213.     or    d0,d1
  214.     move    d1,tcon_tos_date(a0)
  215. ;
  216.     move    tcon_man_hour(a0),d1
  217.     asl    #6,d1
  218.     move    tcon_man_minute(a0),d0
  219.     and    #1<<6-1,d0
  220.     or    d0,d1
  221.     asl    #5,d1
  222.     move    tcon_man_second(a0),d0
  223.     lsr    #1,d0
  224.     and    #1<<5-1,d0
  225.     or    d0,d1
  226.     move    d1,tcon_tos_time(a0)
  227.     movem.l    (sp)+,d0/d1
  228.     rts
  229. .ENDM    code_tcon_man2tos
  230. ;
  231. ;-------------------------------------
  232. ;
  233. .MACRO    tcon_net2man
  234.     _uniref        tcon_net2man
  235.     jsr        code_tcon_net2man
  236. .ENDM    tcon_net2man
  237. ;
  238. .MACRO    code_tcon_net2man
  239. ;Sub converts network time to local human time
  240.     movem.l        d0-d3,-(sp)
  241.     clr.l        d3        ;zero summer adjustment for first lap
  242. .adjust_loop:
  243.     move.l        tcon_net_time(a0),d0
  244.     add.l        tcon_zoneseconds(a0),d0
  245.     add.l        d3,d0        ;add summer adjustment (on second lap when used)
  246.     sub.l        #NET_JAN_1980,d0
  247.     clr        d1        ;prep for seconds mixing
  248.     lsr.l        #1,d0        ;prescale to avoid overflow in remainder
  249.     roxr        d1        ;d1 bit 15 = odd seconds bit
  250.     divu        #NET_DAY/2,d0
  251.     move        d0,d2        ;d2 = whole days from 00:00 tuesday Jan 1st 1980
  252.     clr        d0        ;prep to separate remainder
  253.     swap        d0
  254.     divu        #60/2,d0    ;d0.lo = minutes from midnight
  255.     swap        d0
  256.     move.b        d0,d1        ;d1 = all seconds bits rotated 1 step right
  257.     clr        d0        ;prep to separate hours & minutes
  258.     swap        d0
  259.     divu        #60,d0
  260.     move        d0,tcon_man_hour(a0)
  261.     swap        d0
  262.     move        d0,tcon_man_minute(a0)
  263.     rol        #1,d1
  264.     move        d1,tcon_man_second(a0)    ;this completes time_of_day conversion
  265. ;
  266.     clr.l        d0
  267.     move        d2,d0        ;d0 = d2 = days from Jan 1st 1980
  268.     divu        #4*365+1,d0    ;olympic periods since 1980
  269.     asl        #2,d0        ;are precisely 4 years each (until 2100)
  270.     move        d0,d1        ;d1 = years that formed olympics
  271.     clr        d0        ;prep to separate leap year
  272.     swap        d0        ;d0 = remaining days in last olympic
  273.     cmp        #366,d0        ;first year in olympic is leap year
  274.     bhs.s        .more_years
  275.     subq        #1,d0        ;adjust index for post-leap_day (most common)
  276.     cmp        #58,d0        ;beyond February ?
  277.     bgt.s        .done_years    ;then it is now normalized
  278.     beq.s        .leap_day    ;leap day is treated separately
  279.     addq        #1,d0        ;restore original index for Jan 1..Feb 28
  280.     bra.s        .done_years    ;then treat it as any other year
  281. ;
  282. .leap_day:
  283.     move        #365,d0        ;beyond the table for days in normal years
  284.     bra.s        .done_years
  285.     
  286. ;
  287. .more_years:
  288.     subq        #1,d0        ;remove leap day from days in d0
  289.     divu        #365,d0        ;d0.lo = full years in last olympic
  290.     add        d0,d1        ;d1 = total years since 1980
  291.     swap        d0        ;d0 = day_in_year
  292. .done_years:
  293.     add        #1980,d1    ;d1 = real year
  294.     move        d1,tcon_man_year(a0)
  295.     add        d0,d0            ;prep to index 16 bit words
  296.     move        .day_table(pc,d0.w),d0    ;d0 = month<<8 + date
  297.     clr        d1
  298.     move.b        d0,d1
  299.     lsr        #8,d0
  300.     move        d0,tcon_man_month(a0)
  301.     move        d1,tcon_man_date(a0)
  302.     tst        d3            ;summer adjustment already done ?
  303.     bne.s        .finish_net2man
  304.     move.l        #3600,d3        ;prep to adjust by adding one hour
  305.     tcon_is_summer
  306.     bne        .adjust_loop
  307. .finish_net2man:
  308.     addq        #2,d2        ;adjust weekday offset, so we get sunday=0
  309.     divu        #7,d2
  310.     swap        d2        ;d2 = weekday offset 0=sunday .. 6= saturday
  311.     move        d2,tcon_man_weekday(a0)
  312.     movem.l        (sp)+,d0-d3
  313.     rts
  314. ;
  315. .day_table:
  316.     dc.w    $101,$102,$103,$104,$105,$106,$107,$108,$109,$10A    ;January
  317.     dc.w    $10B,$10C,$10D,$10E,$10F,$110,$111,$112,$113,$114
  318.     dc.w    $115,$116,$117,$118,$119,$11A,$11B,$11C,$11D,$11E,$11F
  319. ;
  320.     dc.w    $201,$202,$203,$204,$205,$206,$207,$208,$209,$20A    ;February
  321.     dc.w    $20B,$20C,$20D,$20E,$20F,$210,$211,$212,$213,$214
  322.     dc.w    $215,$216,$217,$218,$219,$21A,$21B,$21C
  323. ;
  324.     dc.w    $301,$302,$303,$304,$305,$306,$307,$308,$309,$30A    ;March
  325.     dc.w    $30B,$30C,$30D,$30E,$30F,$310,$311,$312,$313,$314
  326.     dc.w    $315,$316,$317,$318,$319,$31A,$31B,$31C,$31D,$31E,$31F
  327. ;
  328.     dc.w    $401,$402,$403,$404,$405,$406,$407,$408,$409,$40A    ;April
  329.     dc.w    $40B,$40C,$40D,$40E,$40F,$410,$411,$412,$413,$414
  330.     dc.w    $415,$416,$417,$418,$419,$41A,$41B,$41C,$41D,$41E
  331. ;
  332.     dc.w    $501,$502,$503,$504,$505,$506,$507,$508,$509,$50A    ;May
  333.     dc.w    $50B,$50C,$50D,$50E,$50F,$510,$511,$512,$513,$514
  334.     dc.w    $515,$516,$517,$518,$519,$51A,$51B,$51C,$51D,$51E,$51F
  335. ;
  336.     dc.w    $601,$602,$603,$604,$605,$606,$607,$608,$609,$60A    ;June
  337.     dc.w    $60B,$60C,$60D,$60E,$60F,$610,$611,$612,$613,$614
  338.     dc.w    $615,$616,$617,$618,$619,$61A,$61B,$61C,$61D,$61E
  339. ;
  340.     dc.w    $701,$702,$703,$704,$705,$706,$707,$708,$709,$70A    ;July
  341.     dc.w    $70B,$70C,$70D,$70E,$70F,$710,$711,$712,$713,$714
  342.     dc.w    $715,$716,$717,$718,$719,$71A,$71B,$71C,$71D,$71E,$71F
  343. ;
  344.     dc.w    $801,$802,$803,$804,$805,$806,$807,$808,$809,$80A    ;August
  345.     dc.w    $80B,$80C,$80D,$80E,$80F,$810,$811,$812,$813,$814
  346.     dc.w    $815,$816,$817,$818,$819,$81A,$81B,$81C,$81D,$81E,$81F
  347. ;
  348.     dc.w    $901,$902,$903,$904,$905,$906,$907,$908,$909,$90A    ;September
  349.     dc.w    $90B,$90C,$90D,$90E,$90F,$910,$911,$912,$913,$914
  350.     dc.w    $915,$916,$917,$918,$919,$91A,$91B,$91C,$91D,$91E
  351. ;
  352.     dc.w    $A01,$A02,$A03,$A04,$A05,$A06,$A07,$A08,$A09,$A0A    ;October
  353.     dc.w    $A0B,$A0C,$A0D,$A0E,$A0F,$A10,$A11,$A12,$A13,$A14
  354.     dc.w    $A15,$A16,$A17,$A18,$A19,$A1A,$A1B,$A1C,$A1D,$A1E,$A1F
  355. ;
  356.     dc.w    $B01,$B02,$B03,$B04,$B05,$B06,$B07,$B08,$B09,$B0A    ;November
  357.     dc.w    $B0B,$B0C,$B0D,$B0E,$B0F,$B10,$B11,$B12,$B13,$B14
  358.     dc.w    $B15,$B16,$B17,$B18,$B19,$B1A,$B1B,$B1C,$B1D,$B1E
  359. ;
  360.     dc.w    $C01,$C02,$C03,$C04,$C05,$C06,$C07,$C08,$C09,$C0A    ;December
  361.     dc.w    $C0B,$C0C,$C0D,$C0E,$C0F,$C10,$C11,$C12,$C13,$C14
  362.     dc.w    $C15,$C16,$C17,$C18,$C19,$C1A,$C1B,$C1C,$C1D,$C1E,$C1F
  363. ;
  364.     dc.w    $21D    ;special entry for leap day
  365. .ENDM    code_tcon_net2man
  366. ;
  367. ;-------------------------------------
  368. ;
  369. .MACRO    tcon_man2net
  370.     _uniref    tcon_man2net
  371.     jsr    code_tcon_man2net
  372. .ENDM    tcon_man2net
  373. ;
  374. .MACRO    code_tcon_man2net
  375. ;Sub converts local human time to network time
  376.     movem.l    d0-d3,-(sp)
  377.     tcon_is_summer
  378.     move.l    #3600,d3
  379.     and    d0,d3
  380.     move    tcon_man_year(a0),d0
  381.     sub    #1980,d0    ;make year relative to 1980
  382.     move    d0,d1
  383.     lsr    #2,d0        ;d0 = olympics
  384.     mulu    #365*4+1,d0    ;d0 = days of full olympics
  385.     and    #1<<2-1,d1    ;d1 = years of current olympic
  386.     seq    d2        ;d2.b=$FF if current year is leaping, else $00
  387.     beq.s    .done_years
  388.     mulu    #365,d1        ;d1 = normal days of full years of current olympic
  389.     addq    #1,d1        ;add a leap day for the first of them
  390.     add    d1,d0        ;d0 = days of all full years  (NB: <65536 !!!)
  391. ;    
  392. .done_years:
  393.     and    #12,d2        ;d2 = table offset for leap year, or zero
  394.     add    tcon_man_month(a0),d2    ;d2 = month index (0-23, with 12-23 for leap years)
  395.     subq    #1,d2        ;subtract one since months don't use zero
  396.     add    d2,d2                ;prep to index 16 bit words
  397.     add    .month_table(pc,d2.w),d0    ;add days before current month to d0
  398.     add    tcon_man_date(a0),d0            ;add date in current month to d0
  399.     subq    #1,d0        ;subtract one, since dates don't use zero
  400.     mulu    #NET_DAY/2,d0
  401.     add.l    d0,d0        ;d0 = date in seconds relative to Jan 1 1980
  402.     add.l    #NET_JAN_1980,d0    ;d0.l = local date (but not yet time) in seconds
  403.     move    tcon_man_hour(a0),d1
  404.     mulu    #60,d1
  405.     add    tcon_man_minute(a0),d1
  406.     mulu    #60/2,d1    ;NB: the "/2" is needed to avoid overflow
  407.     add.l    d1,d1        ;This doubling compensates for the above "/2"
  408.     clr.l    d2
  409.     move    tcon_man_second(a0),d2
  410.     add.l    d2,d1        ;d1.l = local time_of_day in seconds
  411.     add.l    d1,d0        ;d0.l = local time in network format
  412.     sub.l    d3,d0        ;adjust for daylight savings
  413.     sub.l    tcon_zoneseconds(a0),d0    ;d0.l = true network time
  414.     move.l    d0,tcon_net_time(a0)
  415.     movem.l    (sp)+,d0-d3
  416.     rts
  417. ;
  418. .month_table:
  419.     dc.w    0,31,59,90,120,151,181,212,243,273,304,334
  420.     dc.w    0,31,60,91,121,152,182,213,244,274,305,335
  421. .ENDM    code_tcon_man2net
  422. ;
  423. ;-------------------------------------
  424. ;
  425. .MACRO    tcon_is_summer
  426.     _uniref    tcon_is_summer
  427.     jsr    code_tcon_is_summer
  428. .ENDM    tcon_is_summer
  429. ;
  430. .MACRO    code_tcon_is_summer
  431.     move.l    d1,-(sp)
  432.     tst.l    tcon_summer(a0)
  433.     beq.s    .exit_false
  434.     clr.l    d0
  435.     move    tcon_man_month(a0),d0
  436.     add    #12,d0
  437.     sub.b    tcon_summer_start_month(a0),d0
  438.     divu    #12,d0
  439.     swap    d0
  440.     tst    d0    ;start month now ?
  441.     bne.s    .not_start_month
  442. ;start month is now
  443.     move    tcon_man_date(a0),d0
  444.     cmp.b    tcon_summer_start_date(a0),d0
  445.     blo.s    .exit_false
  446. .exit_true:
  447.     move.l    (sp)+,d1
  448.     moveq    #-1,d0
  449.     rts
  450. ;
  451. .not_start_month:
  452.     clr.l    d1
  453.     move.b    tcon_summer_end_month(a0),d1
  454.     add    #12,d1
  455.     sub.b    tcon_summer_start_month(a0),d1
  456.     divu    #12,d1
  457.     swap    d1
  458.     cmp    d1,d0
  459.     bhi.s    .exit_false
  460.     blo.s    .exit_true
  461. ;end month is now
  462.     move    tcon_man_date(a0),d0
  463.     cmp.b    tcon_summer_end_date(a0),d0
  464.     blo.s    .exit_true
  465. .exit_false:
  466.     move.l    (sp)+,d1
  467.     clr.l    d0
  468.     rts
  469. .ENDM    code_tcon_is_summer
  470. ;
  471. ;-------------------------------------
  472. ;
  473. .MACRO    tcon_rd_zone
  474.     _uniref    tcon_rd_zone
  475.     jsr    code_tcon_rd_zone
  476. .ENDM    tcon_rd_zone
  477. ;
  478. .MACRO    code_tcon_rd_zone
  479. ;Sub converts config variable TIME_ZONE to tcon_zoneseconds
  480.     movem.l    d0-d2/a0-a2,-(sp)
  481.     move.l        a0,-(sp)
  482.     getvstr        TIME_ZONE_vn_s(pc)
  483.     is_unblank.i    d0
  484.     clr        d1
  485.     clr.l        d2
  486.     move.l        a0,d0
  487.     beq.s        .have_zone
  488.     move.b        (a0)+,d1
  489.     cmp.b        #'+',d1
  490.     beq.s        .use_sign
  491.     cmp.b        #'-',d1
  492.     beq.s        .use_sign
  493.     subq        #1,a0
  494. .use_sign:
  495.     clr        d0
  496. .loop:
  497.     move.b        (a0)+,d0
  498.     sub.b        #'0',d0
  499.     blt.s        .have_zone
  500.     cmp.b        #9,d0
  501.     bhi.s        .have_zone
  502.     mulu        #10,d2
  503.     add        d0,d2
  504.     cmp        #1440,d2    ;too high ?
  505.     bls.s        .loop        ;loop for legal values
  506.     clr.l        d2        ;force illegal value to zero
  507. .have_zone:
  508.     mulu        #60,d2        ;convert to seconds
  509.     cmp.b        #'-',d1
  510.     bne.s        .keep_sign
  511.     neg.l        d2        ;adjust to negative sign
  512. .keep_sign:
  513.     move.l        (sp)+,a0
  514.     move.l        d2,tcon_zoneseconds(a0)
  515.     movem.l        (sp)+,d0-d2/a0-a2
  516.     rts
  517. ;
  518. TIME_ZONE_vn_s:
  519.     dc.b    'TIME_ZONE',NUL
  520.     even
  521. .ENDM    code_tcon_rd_zone
  522. ;
  523. ;-------------------------------------
  524. ;
  525. .MACRO    tcon_rd_summer
  526.     _uniref    tcon_rd_summer
  527.     jsr    code_tcon_rd_summer
  528. .ENDM    tcon_rd_summer
  529. ;
  530. .MACRO    code_tcon_rd_summer
  531. ;Sub converts config variable TIME_ZONE to tcon_zoneseconds
  532.     movem.l        d0-d2/a0-a2,-(sp)
  533.     move.l        a0,-(sp)
  534.     getvstr        TIME_SUMMER_vn_s(pc)
  535.     is_unblank.i    d0
  536.     move.l        a0,d0
  537.     beq.s        .have_summer
  538.     diptobip    (a0)
  539. .have_summer:
  540.     move.l        (sp)+,a0
  541.     move.l        d0,tcon_summer(a0)
  542.     movem.l        (sp)+,d0-d2/a0-a2
  543.     rts
  544. ;
  545. TIME_SUMMER_vn_s:
  546.     dc.b        'TIME_SUMMER',NUL
  547.     even
  548. .ENDM    code_tcon_rd_summer
  549. ;
  550. ;----------------------------------------------------------------------------
  551. ;End of file:    NET_TCON.SH
  552. ;----------------------------------------------------------------------------
  553.